<?php
/**
 * Created by PhpStorm.
 * Clerk: Administrator
 * Date: 2018/8/24
 * Time: 15:53
 */

namespace app\api\controller\v1;
use app\api\controller\BaseController;
use think\Session;
class Clerk extends BaseController
{

    /**
     * 登录
     * @return \think\response\Json
     */
    public function login(){
        $account = $this->request->post('account');
        if(empty($account)){
            return json_failed(100001);
        }
        $password = $this->request->post('password');
        if(empty($password)){
            return json_failed(100002);
        }

        $islogin = $this->islogin($account,$password);
        if($islogin){
            //生成token并将token存储到session中
            $token = md5($account.$password);
            Session::set($token,$islogin['id']);
            return json_success($token);
        }else{
            return json_failed(100003);
        }
    }


}